function GroundType(){};
GroundType.base = 1;
GroundType.grass = 2;

function getImgSrc(type){
    switch (type){

        case GroundType.grass:
            return "images/grass_h.png";
        default :
            return "images/ground.png";
    }
}

/**
 * base ground
 */
function Ground(x,y,w,h,t){
    this.x = x || 0;
    this.y = y || 0;
    this.width = w || 50;
    this.height = h || 50;
    this.type = t || GroundType.base;
    this.img = new Image();
    this.img.src = getImgSrc(this.type);
    var that = this;
    this.img.onload = function () {
        that.isReady = true;
    }
}

Ground.prototype.render = function(context){
    if(this.isReady){
        context.drawImage(this.img,this.x,this.y,this.width,this.height);
    }
};

function Grid(x,y,w,h){
    this.x = x || 0;
    this.y = y || 0;
    this.width = w || 50;
    this.height = h || 50;
    this.img = new Image();
    this.img.src = "images/terain_maskv1.png";
    var that = this;
    this.img.onload = function(){
        that.isReady = true;
    };
}
Grid.prototype.render = function(context){
    if(this.isReady){
        context.drawImage(this.img,this.x,this.y,this.width,this.height);
    }
};

function Player(x,y,w,h){
    this.x = x || 0;
    this.y = y || 0;
    this.width = w || 50;
    this.height = h || 50;
    this.dw = 50;
    this.dh = 62;
    this.img = new Image();
    this.img.src = "images/kear.png";
    var that = this;
    this.img.onload = function(){
        that.isReady = true;
    };
    this.movePower = 5;
}
Player.prototype.render = function(context){
    if(this.isReady){
        context.drawImage(this.img,this.x,this.y-(this.dh-this.height),this.dw,this.dh);
    }
};




